use std::num::ParseIntError;

type RESULT<T> = Result<T, ParseIntError>;

fn main() {
    println!("Hello, world!");
    print(multiply("10", "2"));
    print(multiply("10", "a"));
}
fn print(result: RESULT<i32>) {
    match result {
        Ok(n) => println!("n is {}", n),
        Err(e) => println!("Error: {}", e),
    }
}
fn multiply(f_str: &str, s_str: &str) -> RESULT<i32> {
    let fi = match f_str.parse::<i32>() {
        Ok(f_num) => f_num,
        Err(e) => return Err(e),
    };
    let sn = match s_str.parse::<i32>() {
        Ok(s_num) => s_num,
        Err(e) => return Err(e),
    };

    Ok(fi * sn)
}
